Skip to content

[Cases] Fix unified event attachments bypassing closed-case check - #291173

Merged
christineweng merged 1 commit into
elastic:mainfrom
christineweng:cases-fix-event-attached-to-closed-case
Sep 15, 2026
Merged

christineweng merged 1 commit into
elastic:mainfrom
christineweng:cases-fix-event-attached-to-closed-case

Conversation

@christineweng

@christineweng christineweng commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

validateCreateCommentRequest blocks alerts and events from being attached to a closed case. The event check matched by legacy type only (AttachmentType.event, i.e. 'event'), so unified events (security.event) never triggered the guard and were silently accepted on closed cases.

Alerts already used the unified-aware isAlertAttachmentType predicate. This aligns events to the same pattern via isEventAttachmentType, which matches both 'event' (legacy) and 'security.event' (unified).

Also removes the now-dead getAttachmentsByType helper (its only call site was the buggy event check).

Found by @radtke-vale, validated on staging in this review comment on #290961.

Before / after (validated on staging)

Before:

POST kbn:/api/cases/{caseId}/comments
{
  "type": "security.event",
  "owner": "securitySolution",
  "attachmentId": "...",
  "metadata": { "index": "..." }
}

200, attachment created on a closed case.

After:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Event cannot be attached to a closed case"
}

Checklist

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

Made with Cursor

validateCreateCommentRequest matched events by `AttachmentType.event`
(legacy shape) only. Unified events use type `security.event`, so
they never triggered the closed-case guard and were silently accepted
on closed cases. Alerts already used the unified-aware
`isAlertAttachmentType` predicate; events now use the equivalent
`isEventAttachmentType` predicate for parity.

Removes the now-unused `getAttachmentsByType` helper (single call
site).
@christineweng
christineweng requested a review from a team as a code owner September 15, 2026 14:33
@christineweng christineweng self-assigned this Sep 15, 2026
@christineweng christineweng added backport:version Backport to applied version labels v9.6.0 v9.5.5 labels Sep 15, 2026

@radtke-vale radtke-vale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Only code review

).rejects.toThrow();
});

it('throws if trying to add a unified (v2) event to a closed case', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@kibanamachine

Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

Test Failures

  • [job] [logs] FTR Configs #65 / Cloud Security Posture - Group 1 (Rules) Cloud Posture Rules Page - Counters "after all" hook in "Cloud Posture Rules Page - Counters"
  • [job] [logs] FTR Configs #65 / Cloud Security Posture - Group 1 (Rules) Cloud Posture Rules Page - Counters "before each" hook for "Clicking the integrations counter button leads to the integration page"
  • [job] [logs] FTR Configs #31 / Journey[login] Login
  • [job] [logs] Scout Lane #50 - serverless-observability_complete / default / local-serverless-observability_complete - Synthetics manage rules privilege - lets a read user with can_manage_rules enable default alerting
  • [job] [logs] Scout Lane #20 - stateful-classic / default / local-stateful-classic - Synthetics manage rules privilege - lets a read user with can_manage_rules enable default alerting

cc @christineweng

@christineweng
christineweng merged commit 0b5aba9 into elastic:main Sep 15, 2026
190 checks passed
@kibanamachine

Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.5

https://github.com/elastic/kibana/actions/runs/34991661799

@kibanamachine

Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
9.5 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 291173

Questions ?

Please refer to the Backport tool documentation

@christineweng

Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
9.5

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

christineweng added a commit that referenced this pull request Sep 15, 2026
…ck (#291173) (#291204)

# Backport

This will backport the following commits from `main` to `9.5`:
- [[Cases] Fix unified event attachments bypassing closed-case check
(#291173)](#291173)

<!--- Backport version: 12.0.4 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT
[{"author":{"name":"christineweng","email":"18648970+christineweng@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-09-15T15:55:18Z","message":"[Cases]
Fix unified event attachments bypassing closed-case check
(#291173)\n\n## Summary\n\n`validateCreateCommentRequest` blocks alerts
and events from being\nattached to a closed case. The event check
matched by legacy type only\n(`AttachmentType.event`, i.e. `'event'`),
so unified events\n(`security.event`) never triggered the guard and were
silently accepted\non closed cases.\n\nAlerts already used the
unified-aware `isAlertAttachmentType` predicate.\nThis aligns events to
the same pattern via `isEventAttachmentType`,\nwhich matches both
`'event'` (legacy) and `'security.event'` (unified).\n\nAlso removes the
now-dead `getAttachmentsByType` helper (its only call\nsite was the
buggy event check).\n\n**Found by** @radtke-vale, validated on staging
in [this
review\ncomment](https://github.com/elastic/kibana/pull/290961#discussion_r4014165733)\non
#290961.\n\n## Before / after (validated on
staging)\n\nBefore:\n```\nPOST kbn:/api/cases/{caseId}/comments\n{\n
\"type\": \"security.event\",\n \"owner\": \"securitySolution\",\n
\"attachmentId\": \"...\",\n \"metadata\": { \"index\": \"...\"
}\n}\n```\n→ `200`, attachment created on a closed
case.\n\nAfter:\n```json\n{\n \"statusCode\": 400,\n \"error\": \"Bad
Request\",\n \"message\": \"Event cannot be attached to a closed
case\"\n}\n```\n\n### Checklist\n\n- [ ] Any text added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[
]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/docs/extend/kibana/contributing/workflow/how-we-use-github#release-notes)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\nMade with
Cursor","sha":"0b5aba9fe5761d0fd2fc2ce576e6d36146231465","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:version","v9.6.0","v9.5.5","Team:Lantern"],"title":"[Cases]
Fix unified event attachments bypassing closed-case
check","number":291173,"url":"https://github.com/elastic/kibana/pull/291173","mergeCommit":{"message":"[Cases]
Fix unified event attachments bypassing closed-case check
(#291173)\n\n## Summary\n\n`validateCreateCommentRequest` blocks alerts
and events from being\nattached to a closed case. The event check
matched by legacy type only\n(`AttachmentType.event`, i.e. `'event'`),
so unified events\n(`security.event`) never triggered the guard and were
silently accepted\non closed cases.\n\nAlerts already used the
unified-aware `isAlertAttachmentType` predicate.\nThis aligns events to
the same pattern via `isEventAttachmentType`,\nwhich matches both
`'event'` (legacy) and `'security.event'` (unified).\n\nAlso removes the
now-dead `getAttachmentsByType` helper (its only call\nsite was the
buggy event check).\n\n**Found by** @radtke-vale, validated on staging
in [this
review\ncomment](https://github.com/elastic/kibana/pull/290961#discussion_r4014165733)\non
#290961.\n\n## Before / after (validated on
staging)\n\nBefore:\n```\nPOST kbn:/api/cases/{caseId}/comments\n{\n
\"type\": \"security.event\",\n \"owner\": \"securitySolution\",\n
\"attachmentId\": \"...\",\n \"metadata\": { \"index\": \"...\"
}\n}\n```\n→ `200`, attachment created on a closed
case.\n\nAfter:\n```json\n{\n \"statusCode\": 400,\n \"error\": \"Bad
Request\",\n \"message\": \"Event cannot be attached to a closed
case\"\n}\n```\n\n### Checklist\n\n- [ ] Any text added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[
]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/docs/extend/kibana/contributing/workflow/how-we-use-github#release-notes)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\nMade with
Cursor","sha":"0b5aba9fe5761d0fd2fc2ce576e6d36146231465"}},"sourceBranch":"main","suggestedTargetBranches":["9.5"],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/291173","number":291173,"mergeCommit":{"message":"[Cases]
Fix unified event attachments bypassing closed-case check
(#291173)\n\n## Summary\n\n`validateCreateCommentRequest` blocks alerts
and events from being\nattached to a closed case. The event check
matched by legacy type only\n(`AttachmentType.event`, i.e. `'event'`),
so unified events\n(`security.event`) never triggered the guard and were
silently accepted\non closed cases.\n\nAlerts already used the
unified-aware `isAlertAttachmentType` predicate.\nThis aligns events to
the same pattern via `isEventAttachmentType`,\nwhich matches both
`'event'` (legacy) and `'security.event'` (unified).\n\nAlso removes the
now-dead `getAttachmentsByType` helper (its only call\nsite was the
buggy event check).\n\n**Found by** @radtke-vale, validated on staging
in [this
review\ncomment](https://github.com/elastic/kibana/pull/290961#discussion_r4014165733)\non
#290961.\n\n## Before / after (validated on
staging)\n\nBefore:\n```\nPOST kbn:/api/cases/{caseId}/comments\n{\n
\"type\": \"security.event\",\n \"owner\": \"securitySolution\",\n
\"attachmentId\": \"...\",\n \"metadata\": { \"index\": \"...\"
}\n}\n```\n→ `200`, attachment created on a closed
case.\n\nAfter:\n```json\n{\n \"statusCode\": 400,\n \"error\": \"Bad
Request\",\n \"message\": \"Event cannot be attached to a closed
case\"\n}\n```\n\n### Checklist\n\n- [ ] Any text added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[
]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/docs/extend/kibana/contributing/workflow/how-we-use-github#release-notes)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\nMade with
Cursor","sha":"0b5aba9fe5761d0fd2fc2ce576e6d36146231465"}},{"branch":"9.5","label":"v9.5.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants